package com.binguo.wxapi.controller;

import com.binguo.helper.PhoneHelper;
import com.binguo.model.model.PadIp;
import com.binguo.model.repository.PadIpRepository;
import com.binguo.wxapi.form.CustomerForm;
import com.binguo.wxapi.form.CustomerGroupForm;
import com.binguo.wxapi.form.MerchantLoginForm;
import com.binguo.wxapi.result.Result;
import com.binguo.wxapi.result.ResultGenerator;
import com.binguo.wxapi.service.WXCustomerService;
import com.binguo.wxapi.vo.ShopInfoVO;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;


/**
 */
@RestController
@RequestMapping
public class WXJapanController {

    private static Logger logger = LoggerFactory.getLogger(WXJapanController.class);

    @Autowired
    PadIpRepository padIpRepository;


    @GetMapping(value = "/api/wxapp/getPadIpAddress", produces = APPLICATION_JSON_VALUE)
    @ApiOperation(value = "获取ip")
    public Result getCustomerGroup(@RequestParam(value = "type", required = false) Integer type) {
        logger.info("获取ip type=={}", type);
        if (type == null) {
            type = 1;
        }

        PadIp padIp = padIpRepository.findBy("ipType", type);

        return ResultGenerator.genSuccessResult(padIp.getAddress());
    }




}
